package com.tac.controller.mes;

import com.github.pagehelper.PageInfo;
import com.tac.common.result.Result;
import com.tac.pojo.mes.ProjectMaintenance;
import com.tac.service.wms.ProjectMaintenanceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

@Api(tags = "制造执行MES--项目维护")
@CrossOrigin
@RestController
@RequestMapping("/projectMaintenance")
public class ProjectMaintenanceController {

    @Autowired
    private ProjectMaintenanceService projectMaintenanceService;

    //查看项目列表
    @GetMapping("/getList")
    @ApiOperation("查看项目列表")
    public Result<PageInfo<ProjectMaintenance>> getList
    (Integer pageNum, Integer pageSize, String projectName,
     @DateTimeFormat(pattern = "yyyy-MM-dd") Date startStartTime,
     @DateTimeFormat(pattern = "yyyy-MM-dd") Date startEndTime,
     @DateTimeFormat(pattern = "yyyy-MM-dd") Date endStartTime,
     @DateTimeFormat(pattern = "yyyy-MM-dd") Date endEndTime, Integer status){
        return projectMaintenanceService.getList
                (pageNum,pageSize,projectName,startStartTime,startEndTime,endStartTime,endEndTime,status);
    }
    //添加项目
    @PostMapping("/save")
    @ApiOperation("添加项目")
    public Result save(@RequestBody ProjectMaintenance projectMaintenance){
        return projectMaintenanceService.save(projectMaintenance);
    }
    //删除项目
    @DeleteMapping("/remove")
    @ApiOperation("删除项目")
    public Result remove(@RequestBody List<Integer> ids){
        return projectMaintenanceService.remove(ids);
    }
    //修改项目
    @PutMapping("/update")
    @ApiOperation("修改项目")
    public Result update(@RequestBody ProjectMaintenance projectMaintenance){
        return projectMaintenanceService.update(projectMaintenance);
    }
}
